package com.admin.application;

import com.admin.domain.modle.Banner;
import com.admin.domain.repository.BannerRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;


/**
 * description
 * User: WeiDa
 * Date: 2017-4-11
 * Time: 16:45
 */
@Service
public class BannerService {

    private static final Logger LOGGER = LoggerFactory.getLogger(BannerService.class);
    @Autowired
    protected BannerRepository bannerRepository;

    public Banner create(Banner banner) {
        banner.setId(UUID.randomUUID().toString());
        bannerRepository.add(banner);
        return banner;
    }

    public Banner modify(Banner banner) {
        bannerRepository.update(banner);
        return banner;
    }

    public Banner get(String code) {
        return bannerRepository.get(code);
    }

    public List<Banner> list(String key) {
        return bannerRepository.list(key);
    }

    public void delete(String code) {
        bannerRepository.remove(code);
    }

}
